<?php
class Administrator_WebmasterRoleController extends QSource_System_Controller_Action
{
    public function init ()
    {
        $this->loadTemplate('administrator');
    }
    public function indexAction ()
    {
        $model = new Model_WebmasterRole_WebmasterRole();
        $name = $this->_request->getParam('name', '');
        $order = $this->_request->getParam('order', '');
        if (($order != '') && ($name != ''))
            $data = $model->getAll($name, $order);
        else
            $data = $model->getAll();
        Zend_View_Helper_PaginationControl::setDefaultViewPartial(
        APPLICATION_PATH . '\modules\administrator\views\pagination.phtml');
        $pa = Zend_Paginator::factory($data);
        $pa->setItemCountPerPage(10);
        $current = $this->_request->getParam('page');
        $this->view->page = $current;
        $pa->setCurrentPageNumber($current);
        $this->view->data = $pa;
    }
	public function addAction ()
    {
     	if($this->_request->isPost()){
     		$model = new Model_WebmasterRole_WebmasterRole();
	     	$name = $this->_request->getParam('name','');
	     	$des = $this->_request->getParam('description','');
	     	if($name == ''){
	     		$err = array ('name'=>'Hãy nhập tên Quyền');
	     		$this->view->error = $err;
	     		return;
	     	}
	     	$data = array ('name'=>$name,'description'=>$des);
	     	$model->insert($data);  
	     	$this->view->success = 'Đã thêm Quyền thành công'; 
     	}
    }
}